let redux = require('redux');
let combineReducers = redux.combineReducers
let bindActionCreators = redux.bindActionCreators



function fn1(state, action) {
    return { ...state, name: '小明' };
}
function fn2(state, action) {
    return { ...state, name: '小红' };
}

// reducers函数的整合
var reducers = { fn1: fn1, fn2: fn2 }
var state = {
    name: ''
}

let store = redux.createStore(combineReducers(reducers), state);

console.log('store 创建成功了')
// console.log(store);

store.subscribe((a) => {
    console.log("dispatch的回调")
    console.log(store.getState());
})

// 派发下事件
store.dispatch({
    type: 'fn1',
    data: {}
});


function createAction() {
    return {
        type: 'REMOVE_TODO',
        name: 10,
    }
}
let aa = bindActionCreators(createAction, store.dispatch)

console.log('我是aa')
aa()